package com.team.recruitment_management_system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team.recruitment_management_system.mapper.EducationExperienceMapper;
import com.team.recruitment_management_system.pojo.dto.education.AddEducationDto;
import com.team.recruitment_management_system.pojo.entity.EducationExperience;
import com.team.recruitment_management_system.pojo.entity.Resume;
import com.team.recruitment_management_system.pojo.vo.ResumeVo;
import com.team.recruitment_management_system.service.EducationExperienceService;
import com.team.recruitment_management_system.service.ResumeService;
import com.team.recruitment_management_system.util.result.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 86147
 * @description 针对表【education_experience(教育经历表)】的数据库操作Service实现
 * @createDate 2024-03-21 20:28:40
 */
@Service
public class EducationExperienceServiceImpl extends ServiceImpl<EducationExperienceMapper, EducationExperience>
        implements EducationExperienceService {
    @Autowired
    EducationExperienceMapper educationExperienceMapper;
    @Autowired
    ResumeService resumeService;

    public Integer update(EducationExperience educationExperience, String token) {
//        ResumeVo resume = resumeService.FindOne(token);
//        Integer resume_id = resume.getId();
//        educationExperience.setResumeId(resume_id);
        return educationExperienceMapper.updateById(educationExperience);
    }

    public List<EducationExperience> findMyEducationExperience(String token) {
        ResumeVo resume = resumeService.FindOne(token);
        Integer resume_id = resume.getId();
        return educationExperienceMapper.selectByResumeId(resume_id);
    }
    public Result addOne(AddEducationDto addEducationDto){
        EducationExperience educationExperience = new EducationExperience();
        BeanUtils.copyProperties(addEducationDto,educationExperience);
        educationExperienceMapper.insert(educationExperience);
        return Result.postOk(null);
    }
}




